﻿<%@ Page Title="" Language="C#" MasterPageFile="~/master/admin.master" AutoEventWireup="true" CodeFile="sales-report.aspx.cs" Inherits="admin_sales_report" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<asp:Content ID="Content1" ContentPlaceHolderID="AdminHeaderContent" Runat="Server">
<script type="text/javascript">
    var CommandHandler = function (command, rowIndex, grid) {
        //showObj(grid);
        grid.getRowEditor().stopEditing();
        grid.getView().refresh();
        grid.getSelectionModel().selectRow(rowIndex);
        grid.getRowEditor().startEditing(rowIndex);
    }
    var categoryGrid;
    var exportOrders = function () {
            // Call DirectMethod
            Polana.WebService.ExportOrders();
     
    }
      
    var searchOrder = function (grid) {
        Polana.WebService.SearchOrder();
    }
    var onDocumentReady = function (grid) {
        categoryGrid = grid;
    }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphMiddleContent" Runat="Server">
    <ext:ResourceManager ID="ScriptManager1" runat="server" Theme="Gray">
        <Listeners>
            <DocumentReady Fn="onDocumentReady(#{GridPanel1})" />
        </Listeners>
    </ext:ResourceManager>
    <ext:Store ID="Store1" runat="server" RemoteSort="true" OnRefreshData="Store1_RefreshData">
        <AutoLoadParams>
            <ext:Parameter Name="sort" Value="ProductId" Mode="Value" />
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="limit" Value="100" Mode="Raw" />
        </AutoLoadParams>
        <Proxy>
            <ext:PageProxy />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="ProductId">
                <Fields>
                    <ext:RecordField Name="ProductId" />
                    <ext:RecordField Name="ProductName" ServerMapping="ProductName" />
                    <ext:RecordField Name="ItemNumber" ServerMapping="ItemNumber" />
                   <ext:RecordField Name="ProductName2" ServerMapping="ProductName2" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <div class="admin-function-top inline">
        <ext:GridPanel ID="GridPanel1" runat="server" EnableViewState="true" AutoHeight="true"
            StoreID="Store1">
            <ColumnModel>
                <Columns>
                    <ext:Column Header="Product Name" DataIndex="ProductName" Sortable="false" Width="350">
                    </ext:Column>
                    <ext:Column Header="Item Number" DataIndex="ItemNumber" Sortable="false" Width="80">
                    </ext:Column>
                    <ext:Column Header="Item Sold" DataIndex="ProductName2" Align="Right" Sortable="false" Width="50">
                      
                    </ext:Column>
                </Columns>
            </ColumnModel>
            <TopBar>
                <ext:Toolbar ID="SearchToolbar2" runat="server" AutoScroll="true">
                    <Items>
                        <ext:DateField ID="txtDateFrom" runat="server" EmptyText="Date From" />
                        <ext:ToolbarSpacer ID="ToolbarSpacer1" runat="server" Width="10px" />
                        <ext:DateField ID="txtDateTo" runat="server" EmptyText="Date To" />
                        <ext:Button ID="btnToolbarSearch" runat="server" Text="Search" Icon="Magnifier">
                            <Listeners>
                                <Click Handler="searchOrder(#{GridPanel1});" />
                            </Listeners>
                        </ext:Button>
                        <ext:ToolbarFill ID="ToolbarFill1" runat="server" />
                          <ext:Button ID="btnToolbarCSVExport" runat="server" Text="Export Report" Icon="ApplicationViewIcons">
                            <Listeners>
                                <Click Handler="exportOrders();" />
                            </Listeners>
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
            </TopBar>
            <LoadMask ShowMask="true" />
            <Listeners>
                <Command Handler="CommandHandler(command, rowIndex, this)" />
            </Listeners>
            <View>
                <ext:GridView ID="GridView1" runat="server" ForceFit="true" >
                </ext:GridView>
            </View>
           
        </ext:GridPanel>
    </div>
    <%--    <script type="text/javascript">
        Ext.override(Ext.grid.GridView, {
            getEditorParent: function () {
                return document.body;
            }
        });
    </script>--%>
</asp:Content>

